package com.pattern.demo.abstracts;

import com.pattern.demo.behavior.FlyBehavior;
import com.pattern.demo.behavior.QuackBehavior;

/**
 * @ClassName: Duck 抽象类
 * @Description:
 * @Date: 2020/8/26 11:30
 * @Author: Song JinGen
 */
public abstract class Duck {

    public FlyBehavior flyBehavior;

    public QuackBehavior quackBehavior;

    public void swim(){
        System.out.println("所有的鸭子都会游泳");
    }
    public void display(){}

    public void performQuack(){
        quackBehavior.quack();
    }
    public void performFly(){
        flyBehavior.fly();
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}
